<?php

use yii\helpers\Html;
use eric\widgets\GridView;
use eric\widgets\Modal;

/* @var $this yii\web\View */
/* @var $searchModel app\models\Bannerssearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', '广告管理');
$this->params['breadcrumbs'][] = $this->title;
?>
<!--BEGIN HEADER-->
<div class="section-header">
    <h3 class="text-standard">
        <i class="fa fa-fw fa-arrow-circle-right text-gray-light"></i>
        <?=$this->title?><small><?=$this->subTitle?></small>
    </h3>
</div>
<!--END HEADER-->
<!--BEGIN BODY-->
<div class="section-body">
    <div class="banners-index">
                        <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
                <p>
            <?= Html::a(Yii::t('app', '添加{modelClass}', [
    'modelClass' => '广告',
]), ['create?partial=1'], [
                'class' => 'btn btn-support1',
                'data-toggle' => 'modal',
                'data-target' => '#banners_modal'
            ]) ?>
        </p>

                    <?= GridView::widget([
            'dataProvider' => $dataProvider,
            'options' => ['id' => 'banners_grid'],
            'filterModel' => $searchModel,
           'columns' => [
//                        'id',
            'title',
//            'media_url:url',
//            'ad_id',
               [
                   'attribute'=>'ad_id',
                   'value'=>function($model,$key,$index,$grid){
                       $arr=\app\models\Advert::find()->where(['id'=>$model->ad_id])->asArray()->one();
                       return $arr['name'];
                   },
                   'filter'=>\app\models\Advert::getAdvert(),
               ],
//            'create_time',
               [
                 'attribute'=>'create_time',
                   'value'=>function($model,$key,$index,$grid){
                         return date("Y-m-d H:i",$model->create_time);
                   },
                   'filter'=>false,
               ],
            // 'link_url:url',

            [
                'class' => 'eric\widgets\ActionColumn',
                'modalId' => 'banners_modal'
            ],
            ],
            ]); ?>
        
    </div>
</div>
<!--END BODY-->
<?php
    Modal::begin([
        'options' => [
            'id' => 'banners_modal'
        ],
        'size'=>Modal::SIZE_LARGE,
        'header' => 'banners panel',
    ]);
    Modal::end();
?>


